package com.lzs.baseruku.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzs.baseruku.mapper.WarehouseMapper;
import com.lzs.baseruku.service.WarehouseService;
import com.lzs.entity.Warehouse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 仓库管理 服务实现类
 * </p>
 *
 * @author ymx
 * @since 2020-11-23
 */
@Service
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse> implements WarehouseService {

    @Override
    public Page<Warehouse> selectWarehouse(Integer page, Integer limit, Warehouse warehouse) {
        Page<Warehouse> pageInfo=new Page<>(page,limit);
        String name=warehouse.getName();
        String alias=warehouse.getAlias();
        QueryWrapper queryWrapper=new QueryWrapper();
        if (StringUtils.isNotEmpty(name)){
            queryWrapper.like("name",name);
        }
        if (StringUtils.isNotEmpty(alias)){
            queryWrapper.like("alias",alias);
        }
        this.baseMapper.selectPage(pageInfo,queryWrapper);
        return pageInfo;
    }
}
